<TMPL_INCLUDE name=header.html>
<div id=add_status></div>
<div id=addr_list>
    <TMPL_INCLUDE name=addr_list.html>
</div>
<hr size=1>
<a name=new>
<TMPL_INCLUDE name=new_address.html>
<TMPL_INCLUDE name=footer.html>

<script>
function ChangeGroup(recipient_id, recipient_group_id) {
    Modalbox.show("<TMPL_VAR name=APP_PATH>/cgi-bin/admin/groups/ChangeGroup?recipient_id=" + recipient_id + "&recipient_group_id=" + recipient_group_id,
                  {title: 'change group', width: 600});
}

function replace_group()
{
    if ($('changegroup_recipient_id').value == -1) exit;
    URL	= "groups/ChangeGroup";
    PARAMS	= "action=replace" + 
    					"&target_group_id=" + $('changegroup_target_group_id').value + 
//    					"&recipient_id=" + $('changegroup_recipient_id').value + 
    					"&current_recipient_group_id=" + $('changegroup_current_recipient_group_id').value + 
    					"&type_id=" + $('changegroup_type_id').value;

		alert(PARAMS); exit;

		new Ajax.Request(URL, {parameters: PARAMS, onComplete: RefreshRecipientList,});
		HideModalBox();
}

function add_recipient_to_group()
{
    if ($('changegroup_recipient_id').value == -1) return;
    if ($('changegroup_group_id').value == -1) return;
    URL	= "groups/ChangeGroup";
    PARAMS	= "action=add_recipient_to_group&group_id=" + $('changegroup_group_id').value + "&recipient_id=" + $('changegroup_recipient_id').value;

    new Ajax.Updater('ajaxresult', URL, 
                    {
                        parameters: PARAMS, 
                        onLoading: PrintStatus('header_status', 'Updating recipient records...'),
                        onComplete:ClearStatus,
                    });

    HideModalBox();
}

function RefreshRecipientList()
{
    URL	= location.href;
    PARAMS	= "action=refresh";
    new Ajax.Updater('addr_list', URL, 
                    { parameters: PARAMS, 
                        onLoading: PrintStatus('header_status', 'Updating recipient records...'),
                        onComplete:ClearStatus,
                    }
                    );
}

function PaginatorControl(control)
{
    URL	= location.href;
    PARAMS	= "action=refresh&paginator=" + control;
    new Ajax.Updater('addr_list', URL, {parameters: PARAMS, onLoading: PrintStatus('addr_list', '<div style="height:400px;">Updating recipient records....</div>')});
}
</script>